<%@ page language="java"  pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib  uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>友情链接管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<LINK href="resource/css/admin.css" type="text/css" rel="stylesheet">
	<LINK href="resource/css/style.css" type="text/css" rel="stylesheet">
	<style type="text/css">
    body{font-family:"Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; font-size:12px; color:#555555;}
    .bluebg{
	background:#C4DFF9;
	height:25px;
	width:150px;
}
  </style>
   <script type="text/javascript" src="scripts/sorttable.js"></script> 
   <script type="text/javascript" src="<%=basePath%>scripts/jquery-1.4.2.js"></script>
   <script type="text/javascript">
            var basePath="<%=basePath%>";
        	function selectAllChkboxs(flag)
	        {
	        var getChkboxs = document.getElementsByName("box");
	        for(var i=getChkboxs.length-1;i>=0;i--)
	        {
	          getChkboxs[i].checked=flag;
	        }
	       }
             function   deletebox(){
             var flag=false;
             var  deleteString="";
           var  checks=document.getElementsByName("box");
           for(var i=0;i<checks.length;i++){
	           if(checks[i].checked){
	                 var  idvalue=checks[i].value;
	                 flag=true;
	               deleteString+=idvalue+"_";
	               
	           }
	       }
          if(!flag){
              alert('请选择要删除的记录');
          }else{
             
              var url1 = basePath+"link/deleteAllLink.shtml";
           $.ajax({
                   url: url1,
                   data: "id="+deleteString,
                 success: function(msg){
                     
                     var obj=eval('('+msg+')');
                     var result=obj[0]["message"];
                     alert(result);
                     window.location.reload();
                    
                 }
                });
          }
      }
      function   editClick(id){
          document.getElementById("frame").src="link/getSomeById.shtml?id="+id;			
      }
      
   </script>
   
  </head>
  
  <body>
      
        <s:if test="#list.size()==0">
           <center> 对不起， 没有友情链接信息</center>
       </s:if>
    <s:else>
        <div style="height:150px;overflow-y:scroll;float:left; align:center;">
        <table class="dt1 sortable scrolltable "  border="0" cellpadding="1" cellspacing="1" align="center" width="100%" >
			<tr class="th1">
			
				<td class="w1">
					
				</td>
				<td class="w2 column_sortable">
					链接名称
				</td>
				<td class="w3  column_sortable">
					链接的url
				</td>
				<td class="w4  column_sortable">
					logoUrl
				</td>
				<td class="w5  column_sortable">
					序号
				</td>
				<td class="w6  column_sortable">
					操作栏
				</td>
			</tr>
			  <s:iterator id="link" value="list">
               <tr class="bluebg"><td class="w1">
					<input type="checkbox" name="box" value="${link.id}"/>
				</td><td>${link.name}</td><td>${link.url}</td><td>${link.logoUrl}</td><td>${link.orderNum}</td>
					<td >
					 <a href="javascript:void(0)" onclick='editClick(${link.id})'> 修改</a>
				</td>
                </tr>
            </s:iterator>
        </table>  
      </div>
      <table>
		<tr>
				<td width="250">
					
					<input type="button" value="全选" name="ChkAll1" id="ChkAll1" onclick="selectAllChkboxs(true);" />
					<input type="button" value="清空" name="ChkAll2" id="ChkAll2" onclick="selectAllChkboxs(false);" />
					<input type="button" id="Alldelete"  value="删除服务器"  onclick="deletebox();"/>
				</td>
      </tr>
      </table>
   </s:else>
      <div align="center" id="editdiv">
         <IFRAME  width=1200 frameBorder=0 id="frame" src="back/jsp/addlink.jsp" height=300  scrolling=no ></IFRAME>
	  </div>
  </body>
</html>
